package com.ylr.send.framework.controller.web;

import com.ylr.send.framework.service.SmsLogService;
import com.ylr.base.common.dto.PageDto;
import com.ylr.send.common.dto.SmsLogDetailDto;
import com.ylr.send.common.dto.SmsLogDto;
import com.ylr.base.common.tool.Result;
import com.ylr.send.common.vo.SmsLogFormVo;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.web.bind.annotation.*;


/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-06-14 21:23:18
 * className: SmsLogWebController
 * version: 1.0
 * description:
 */
@RestController
@RequestMapping("/web/sms-log")
@AllArgsConstructor
public class SmsLogWebController {

    private static final Logger log = LoggerFactory.getLogger(SmsLogWebController.class);

    private final SmsLogService smsLogService;

    /**
     * 分页查询短信发送记录接口
     * @param smsLogFormVo 参数对象
     * @return 短信发送记录分页数据
     */
    @PostMapping("/page/list")
    public Result<PageDto<SmsLogDto>> pageSmsLogList(@RequestBody SmsLogFormVo smsLogFormVo) {
        log.info("web => 开始分页查询短信发送记录操作。{}", smsLogFormVo);

        PageDto<SmsLogDto> pageDto = smsLogService.pageSmsLogList(smsLogFormVo);

        log.info("web => 分页查询短信发送记录操作结束");
        return Result.success(pageDto);
    }

    /**
     * 获取短信发送记录接口
     * @param id 主键
     * @return 短信发送记录数据
     */
    @GetMapping("/get")
    public Result<SmsLogDto> getSmsLog(@RequestParam("id") Long id) {
        log.info("web => 开始获取短信发送记录操作。id={}", id);

        SmsLogDto smsLogDto = smsLogService.getSmsLog(id);

        log.info("web => 获取短信发送记录操作结束");
        return Result.success(smsLogDto);
    }

    /**
     * 获取短信发送明细接口
     * @param id 主键
     * @return 短信发送明细
     */
    @GetMapping("/get/detail")
    public Result<SmsLogDetailDto> getSmsLogDetail(@RequestParam("id") Long id) {
        log.info("web => 开始获取短信发送明细操作。id={}", id);

        SmsLogDetailDto smsLogDetailDto = smsLogService.getSmsLogDetail(id);

        log.info("web => 获取短信发送明细操作结束");
        return Result.success(smsLogDetailDto);
    }

}
